[LegacyColorValue = true]; 

{ TSM Moving Channels
  Copyright 1999, P.J.Kaufman. All rights reserved.

  Returns the width of the Bollinger band as measured from the moving average value.
  To create an upper and lower band, add and subtract this value from a trend value. 

  PLOT INSTRUCTIONS: Plot on same graph as price, scaled to price.

  length = calculation period
  factor=  scaling factor }

	inputs:		length(20), factor(3.0);
	vars:		avg(0), middlepoint(0), upper(0), bottom(0), avgrange(0);

	avg = (high + low + close) / 3;
	middlepoint = average(avg,length);
	avgrange = average(high - low,length);

 { 1-period ahead forecast of channel }
	upper = middlepoint + (middlepoint - middlepoint[1]) + factor*avgrange;
	bottom = middlepoint + (middlepoint - middlepoint[1]) - factor*avgrange;

	plot1(upper,"TSMupper");
	plot2(bottom,"TSMlower"); 

